import React, { Component } from 'react'
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'
import { Toast } from 'native-base'
import { Actions } from 'react-native-router-flux'
import Iconfont from '../../../components/iconfont'
import commonStyle from '../../../libs/commonStyle'
export default class Nav extends Component {
	parentIdHandle () {
		this.props.showDialog && this.props.showDialog('已绑定师傅ID， 不能修改')
	}
	render() {
		return (
			<View
				style={[
					commonStyle.backgroundColorWhite,
					commonStyle.flexRow,
					commonStyle.flexVerticalCenter,
					commonStyle.flexWrap
				]}
			>
				{this.props.list &&
					this.props.list.map((item, index) => {
						return (
							<TouchableOpacity
								activeOpacity={0.5}
								key={index}
								style={[
									styles.item,
									commonStyle.flexCenter
								]}
								onPress={() => {
									if ((item.key === 'parentId') && (item.type === '')) {
										this.parentIdHandle()
										return
									}
									item.type &&
									Actions[item.type] &&
									Actions[item.type](
										item.type === 'oneInput'
											? {
													apiMethod: item.apiMethod,
													paramKey: item.key,
													vali: item.vali
											  }
											: {}
									)
								}
								}
							>
								<Iconfont
									name={item.icon}
									size={30}
									color={item.color || '#FF0033'}
								/>
								<Text
									style={[
										commonStyle.mt10,
										{ color: '#444' }
									]}
								>
									{item.title}
								</Text>
								{!!item.subTitle && (
									<View
										style={[
											commonStyle.flexRow,
											commonStyle.flexCenter,
											commonStyle.mt10
										]}
									>
										{item.isAmount && (
											<Iconfont
												name="money4"
												style={[commonStyle.f26]}
											/>
										)}
										<Text
											style={[
												commonStyle.f30,
												commonStyle.fontBold
											]}
										>
											{item.subTitle}
										</Text>
									</View>
								)}
							</TouchableOpacity>
						)
					})}
			</View>
		)
	}
}

const styles = StyleSheet.create({
	item: {
		width: '33.33333333333%',
		borderWidth: 0.5,
		borderStyle: 'solid',
		borderColor: '#f5f5f5',
		height: 110
	}
})
